document.addEventListener('DOMContentLoaded', function () {
    const textInput = document.getElementById('text-input');
    const generateBtn = document.getElementById('generate-qr-btn');
    const qrCodeContainer = document.getElementById('qr-code-container');
  
    generateBtn.addEventListener('click', function () {
      const inputText = textInput.value;
      if (inputText) {
        // 清空之前的二维码（如果有）
        qrCodeContainer.innerHTML = '';
        // 创建二维码实例并显示
        const qr = new QRCode(qrCodeContainer, {
          text: inputText,
          width: 128,
          height: 128
        });
      }
    });
  });